/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.manageBean;

import br.com.beans.Imagens;
import br.com.genericInterface.dao.ImagensDAOImple;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;


/**
 *
 * @author Unix
 */
@ManagedBean
@SessionScoped
public class ImagensMB{
    
    private List<StreamedContent> listaImgs = new ArrayList<>();
    private List<Imagens> listaImgs2 = new ArrayList<>();
    
    public ImagensMB() {
    }
        
    @PostConstruct
    public void ListarImgs()
    {       
        listaImgs2 = new ImagensDAOImple().getAllImagens();
        
        for (Imagens imagens : listaImgs2) 
        {
            InputStream stream = new ByteArrayInputStream(imagens.getImg());
            StreamedContent streamedContent = new DefaultStreamedContent(stream, "image/jpg");
            listaImgs.add(streamedContent);
        }
    }

    public List<StreamedContent> getListaImgs() {
        return listaImgs;
    }

    public void setListaImgs(List<StreamedContent> listaImgs) {
        this.listaImgs = listaImgs;
    }
    
    
     
}
